import 'package:flutter/material.dart';

class NewsComments extends StatefulWidget {
  const NewsComments({super.key});

  @override
  State<NewsComments> createState() => _NewsCommentsState();
}

class _NewsCommentsState extends State<NewsComments> {
  List<Widget> boxs = [];

  final _TextController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
      ),
      body: ListView(
        children: [
          Container(
            margin: EdgeInsets.all(20),
            child: Column(
              children: [
                Container(
                  height: 200,
                  child: TextField(
                    controller: _TextController,
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    setState(() {
                      if (_TextController.text != '') {
                        boxs.add(Container(
                          width: MediaQuery.of(context).size.width,
                          height: 200,
                          color: Colors.yellow,
                          child: Row(
                            children: [
                              Container(
                                margin: EdgeInsets.symmetric(horizontal: 20),
                                width: 80,
                                height: 80,
                                color: Colors.pink[200],
                              ),
                              Expanded(
                                child: Container(
                                  padding: EdgeInsets.all(10),
                                  height: 140,
                                  color: Colors.white,
                                  child: Text(
                                    _TextController.text,
                                  ),
                                ),
                              )
                            ],
                          ),
                        ));
                      } else {}
                    });
                    print(boxs);
                  },
                  child: Container(
                    height: 40,
                    color: Colors.pink[200],
                  ),
                ),
                Column(
                  children: boxs,
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
